package com.mall.biz.eshop;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.mall.client.eshop.EshopTradeService;
import com.mall.pojo.EshopTrade;
import com.mall.pojo.EshopTradeExample;
import com.mall.query.Page;

@Service
/**
 * 买个店订单
 * @author Administrator
 *
 */
public class EshopTradeBizImpl {

	@Autowired
	private EshopTradeService eshopTradeService;

	public List<EshopTrade> getEshopTradeListByUserIdAndOnlyKey(Long userId, Integer onlyKey,Integer status,Page page) {
		EshopTradeExample eshopTradeExample = new EshopTradeExample();
		if(page != null){
			eshopTradeExample.setLimit(page.getLength());
			eshopTradeExample.setStart(page.getBegin());
		}
		eshopTradeExample.setOrderByClause("id desc");
		com.mall.pojo.EshopTradeExample.Criteria criteria = eshopTradeExample.createCriteria();
		if(userId != null){
			criteria.andBuyUserIdEqualTo(userId);
		}
		if(status != null){
			criteria.andStatusEqualTo(status);
		}
		criteria.andCommOnlyKeyEqualTo(onlyKey);
		return this.eshopTradeService.getEshopTradeListByEshopTradeExample(eshopTradeExample);
	}
}
